#!/bin/sh
#
# Copyright (C) 2000-2023 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# shell script to delete Bacula tables for MySQL

bindir=@MYSQL_BINDIR@
db_name=@db_name@

if $bindir/mysql $* <<END-OF-DATA
USE ${db_name};
drop TABLE IF EXISTS MalwareMD5;
drop TABLE IF EXISTS MalwareSHA256;
drop TABLE IF EXISTS FileEvents;
DROP TABLE IF EXISTS MetaEmail;
DROP TABLE IF EXISTS MetaAttachment;
DROP TABLE IF EXISTS TagJob;
DROP TABLE IF EXISTS TagClient;
DROP TABLE IF EXISTS TagMedia;
DROP TABLE IF EXISTS TagObject;
DROP TABLE IF EXISTS Object;
DROP TABLE IF EXISTS Events;
DROP TABLE IF EXISTS Filename;
DROP TABLE IF EXISTS Path;
DROP TABLE IF EXISTS LongName;
DROP TABLE IF EXISTS Device;
DROP TABLE IF EXISTS Storage;
DROP TABLE IF EXISTS MediaType;
DROP TABLE IF EXISTS File;
DROP TABLE IF EXISTS Client;
DROP TABLE IF EXISTS Job;
DROP TABLE IF EXISTS JobHisto;
DROP TABLE IF EXISTS Media;
DROP TABLE IF EXISTS JobMedia;
DROP TABLE IF EXISTS FileMedia;
DROP TABLE IF EXISTS Pool;
DROP TABLE IF EXISTS MultiVolume;
DROP TABLE IF EXISTS FileSave;	 
DROP TABLE IF EXISTS FileSet;	
DROP TABLE IF EXISTS Version;
DROP TABLE IF EXISTS Counters;
DROP TABLE IF EXISTS BaseFiles;
DROP TABLE IF EXISTS UnsavedFiles;
DROP TABLE IF EXISTS CDImages;
DROP TABLE IF EXISTS Status;
DROP TABLE IF EXISTS MAC;
DROP TABLE IF EXISTS Log;
DROP TABLE IF EXISTS Location;
DROP TABLE IF EXISTS LocationLog;
DROP TABLE IF EXISTS PathVisibility;
DROP TABLE IF EXISTS PathHierarchy;
DROP TABLE IF EXISTS RestoreObject;
DROP TABLE IF EXISTS Snapshot;
END-OF-DATA
then
   echo "Deletion of ${db_name} MySQL tables succeeded."
else
   echo "Deletion of ${db_name} MySQL tables failed."
fi
exit 0
